package com.qq2008.game.mojie.jdo;

import com.qq2008.game.mojie.utils.CommonUtil;

// 玩家
public class Role extends com.qq2008.game.mojie.jdo.Player {

    // 编号
    private int userId = 0;

    // 当前经验
    private int exp = 0;

    // 升级所需经验
    private int maxExp = 0;

    // 当前金币
    private int money = 0;

    /***
     * 增加经验
     * @param addExp
     */
    public void addExp(int addExp){
        if(addExp > 0){
            this.exp += addExp;
        }
        if(this.exp >= this.maxExp){
            this.upLv();
        }
    }

    /***
     * 升级
     */
    public void upLv(){
        this.exp -= this.maxExp;
        this.level += 1;
        this.maxExp = CommonUtil.calcUpExp(this.level);
        this.minAttack = this.level * 10 + 20;
        this.maxAttack = this.level * 10 + 60;
        this.minDefence = this.level * 8 + 15;
        this.maxDefence = this.level * 8 + 45;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getExp() {
        return exp;
    }

    public void setExp(int exp) {
        this.exp = exp;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    public int getMaxExp() {
        return maxExp;
    }

    public void setMaxExp(int maxExp) {
        this.maxExp = maxExp;
    }
}
